package xyz.xpman.prisonerfitness.entity;

import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import xyz.xpman.prisonerfitness.util.JsonUtil;

public class TrainingAction {
    public static final String IMG = "img";

    private final List<String> images;


    public TrainingAction(String[] img) {
        if (null == img) {
            this.images = Collections.emptyList();
        } else {
            this.images = Arrays.asList(img);
        }
    }


    public List<String> getImages() {
        return images;
    }



    public static TrainingAction byJson(@NotNull JSONObject json) {
        String[] images = null;

        try {
            images = JsonUtil.toStringArray(json.getJSONArray(IMG));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new TrainingAction(images);
    }

}
